<?php
	include('time.php');

	$html_url = $_SERVER['HTTP_REFERER'];//获取来路
	$html_arr= explode("/",$html_url);
	$html_no = sizeof($html_arr);
	$html_file = $html_arr[$html_no-1];//取得来路文件名
	$html_type = explode("-",str_replace(".html","",$html_file));//置于数组.取得类别和ID

	if(!$html_type[1] == 'html')
	{
		exit;//非静态文件不执行生成
	}
	if(time() - filemtime("../../../".$html_file) > HTML_TIME)//判断文件是否在缓存周期内
	{
		if($html_file == '' || $html_file == 'index')
		{
			break;
		}
		require_once("../../../init.php");
		$html_articlefile = @file_get_contents(BLOG_URL."?".$html_type[0]."=".$html_type[1]);
		$html_articlefile = str_replace("<form action=\"\" method=\"post\">","<form action=\"./?post=".$html_type[1]."\" method=\"post\">",$html_articlefile);//替换加密日志的表单地址
		$html_writehtml = fopen("../../../".$html_type[0]."-".$html_type[1].".html","w");
		if(@fwrite($html_writehtml,$html_articlefile));//更新HTML
		{
			fclose($html_writehtml);	
			echo "window.parent.location.href='./".$html_file."'";//刷新当前页面
		}
	}
?>